package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.EmaiLint;
import com.pgybook.db.entity.domain.EmaiLintEx;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface EmaiLintMapper {
    int countByExample(EmaiLintEx example);

    int deleteByExample(EmaiLintEx example);

    @Delete({
            "delete from emailint",
            "where EMAILID = #{emailid,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long emailid);

    @Insert({
            "insert into emailint (EMAILTYPE, CUSTID, ",
            "SUBJECT, ISHTML, ",
            "BODY, CRTTIME, ",
            "TOLIST, FROMLIST, ",
            "STATUS, SENTTIME)",
            "values (#{emailtype,jdbcType=INTEGER}, #{custid,jdbcType=BIGINT}, ",
            "#{subject,jdbcType=VARCHAR}, #{ishtml,jdbcType=INTEGER}, ",
            "#{body,jdbcType=VARCHAR}, #{crttime,jdbcType=TIMESTAMP}, ",
            "#{tolist,jdbcType=VARCHAR}, #{fromlist,jdbcType=VARCHAR}, ",
            "#{status,jdbcType=INTEGER}, #{senttime,jdbcType=TIMESTAMP})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "emailid", before = false, resultType = Long.class)
    int insert(EmaiLint record);

    int insertSelective(EmaiLint record);

    List<EmaiLint> selectByExample(EmaiLintEx example);

    @Select({
            "select",
            "EMAILID, EMAILTYPE, CUSTID, SUBJECT, ISHTML, BODY, CRTTIME, TOLIST, FROMLIST, ",
            "STATUS, SENTTIME",
            "from emailint",
            "where EMAILID = #{emailid,jdbcType=BIGINT}"
    })
    @ResultMap("BaseResultMap")
    EmaiLint selectByPrimaryKey(Long emailid);

    int updateByExampleSelective(@Param("record") EmaiLint record, @Param("example") EmaiLintEx example);

    int updateByExample(@Param("record") EmaiLint record, @Param("example") EmaiLintEx example);

    int updateByPrimaryKeySelective(EmaiLint record);

    @Update({
            "update emailint",
            "set EMAILTYPE = #{emailtype,jdbcType=INTEGER},",
            "CUSTID = #{custid,jdbcType=BIGINT},",
            "SUBJECT = #{subject,jdbcType=VARCHAR},",
            "ISHTML = #{ishtml,jdbcType=INTEGER},",
            "BODY = #{body,jdbcType=VARCHAR},",
            "CRTTIME = #{crttime,jdbcType=TIMESTAMP},",
            "TOLIST = #{tolist,jdbcType=VARCHAR},",
            "FROMLIST = #{fromlist,jdbcType=VARCHAR},",
            "STATUS = #{status,jdbcType=INTEGER},",
            "SENTTIME = #{senttime,jdbcType=TIMESTAMP}",
            "where EMAILID = #{emailid,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(EmaiLint record);
}
